Closed Bug 576467 Opened 15 years ago Closed 15 years ago

return value from clock_getres should be checked

Categories

(Core :: XPCOM, defect)

x86
Linux
defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: timeless, Assigned: cjones)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity)

Attachments

(1 file)

Most bugs I've filed based on Coverity rely on information Coverity gains from Mozilla's codebase. This is an exception. Here, Coverity was run against a larger system and has determined that everyone else (dbus, glibc, gstreamer, perl, and pulseaudio) checks it. Unchecked call A function was called without checking the return value. Prevent inferred that the return value should be checked based on the checked calls shown below. Called function "clock_getres" whose return value should be checked (checked 6 out of 7 times) xulrunner/xpcom/ds/TimeStamp_posix.cpp 112 // measurable resolution is either incredibly low, ~1ns, or very 113 // high. fall back on clock_getres() 114 struct timespec ts; Event check_return: Called function "clock_getres" whose return value should be checked (checked 6 out of 7 times) Event unchecked_value: Return value of "clock_getres(1, &ts)" is not checked 115 clock_getres(CLOCK_MONOTONIC, &ts); 116 117 minres = TimespecToNs(ts); 118 } dbus/dbus-sysdeps-pthread.c 350 { 351 #ifdef HAVE_MONOTONIC_CLOCK 352 struct timespec dummy; 353 if (clock_getres (CLOCK_MONOTONIC, &dummy) == 0) 354 have_monotonic_clock = TRUE; 355 #endif 356 } glibc/nscd/connections.c 1835 # if _POSIX_CLOCK_SELECTION == 0 1836 if (sysconf (_SC_CLOCK_SELECTION) > 0) 1837 # endif 1838 if (clock_getres (CLOCK_MONOTONIC, &dummy) == 0 1839 && pthread_condattr_setclock (&condattr, CLOCK_MONOTONIC) == 0) 1840 timeout_clock = CLOCK_MONOTONIC; 1841 #endif gstreamer/gst/gstsystemclock.c 534 535 ptype = clock_type_to_posix_id (sysclock->priv->clock_type); 536 537 if (G_UNLIKELY (clock_getres (ptype, &ts))) 538 return GST_CLOCK_TIME_NONE; 539 540 return GST_TIMESPEC_TO_TIME (ts); perl/ext/Time-HiRes/HiRes.xs 1144 #ifdef TIME_HIRES_CLOCK_GETRES_SYSCALL 1145 status = syscall(SYS_clock_getres, clock_id, &ts); 1146 #else 1147 status = clock_getres(clock_id, &ts); 1148 #endif 1149 RETVAL = status == 0 ? ts.tv_sec + (NV) ts.tv_nsec / (NV) 1e9 : -1; 1150 pulseaudio/src/pulsecore/core-rtclock.c 81 struct timespec ts; 82 83 #ifdef CLOCK_MONOTONIC 84 if (clock_getres(CLOCK_MONOTONIC, &ts) >= 0) 85 return ts.tv_sec == 0 && ts.tv_nsec <= PA_HRTIMER_THRESHOLD_USEC*1000; 86 #endif 87 88 pa_assert_se(clock_getres(CLOCK_REALTIME, &ts) == 0); 89 return ts.tv_sec == 0 && ts.tv_nsec <= PA_HRTIMER_THRESHOLD_USEC*1000;
FWIW clock_getres() on Linux is infallible if the specified clock exists, which is already checked by the time we call clock_getres(). But we don't gain anything by not checking the return value, and I'm all for making coverity happy.
Assignee: nobody → jones.chris.g
Attachment #455780 - Flags: review?(roc)
yeah, in a previous run through coverity i checked this code and decided it wasn't interesting. but obviously that's a losing proposition since each coverity run user wastes time doing that. thanks for agreeing to save scan readers :)
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: